<?php

namespace support\Service;

use support\Backend\BackendService;
use support\Container;
use support\Model\UserModel;

class UserService extends BackendService
{

    public function __construct()
    {
        $this->model = Container::get(UserModel::class);
    }

    /**
     * @param int $userId
     * @return array
     */
    public function getUserInfo(int $userId): array
    {
        $info = $this->model->getInfoById($userId);
        // 返回信息
        $result = [];
        $result['avatar'] = $info['avatar'];
        $result['username'] = $info['username'];
        $result['realname'] = $info['realname'];
        $result['nickname'] = $info['nickname'];
        $result['mobile'] = $info['mobile'];
        $result['email'] = $info['email'];
        $result['intro'] = $info['intro'];
        $result['gender'] = $info['gender'];
        $result['roles'] = [];
        return $result;
    }

    public function getUserCountByWhere($where)
    {
        return $this->model->getCountByWhere($where);
    }
}
